package com.example.coupon.controller;

import lombok.Data;

import java.lang.reflect.Field;

/**
 * @author: lj
 * @since: 11/4/2023 19:48
 * @description:
 */
public class main {
    public static void main(String[] args) throws NoSuchFieldException, IllegalAccessException, ClassNotFoundException, InstantiationException {
        testA testA = new testA();
        testA.setName("lee");
        testA.setPhone("110");
        String fstr = "name";
        String str = "1";
        if (str.equals("1")) {
            Field field = testA.getClass().getDeclaredField(fstr);
            field.setAccessible(true);
            String name = (String) field.get(testA);
            System.out.println(name);
        }
    }
}

@Data
class testA {
    private String name;
    private String phone;
}

@Data
class testB {
    private String age;
}
